home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 1.iso / ARGONET / PD / PROGRAMMING / DESKLIBC / SOURCES.ZIP / DeskLib / !DLSources / Libraries / KernelSWIs / c / ReadVarVal
Text File  |  1995-07-08  |  1KB  |  45 lines

  1. /*
  2.     ####             #    #     # #
  3.     #   #            #    #       #          The FreeWare C library for 
  4.     #   #  ##   ###  #  # #     # ###             RISC OS machines
  5.     #   # #  # #     # #  #     # #  #   ___________________________________
  6.     #   # ####  ###  ##   #     # #  #                                      
  7.     #   # #        # # #  #     # #  #    Please refer to the accompanying
  8.     ####   ### ####  #  # ##### # ###    documentation for conditions of use
  9.     ________________________________________________________________________
  10.  
  11.     File:    KernelSWIs.ReadVarVal.c
  12.     Author:  Copyright © 1994 Tim Browse
  13.     Version: 1.00 (30 May 1994)
  14.     Purpose: Function to read an environment variable's value.
  15. */
  16.  
  17. #include "DeskLib:Core.h"
  18. #include "DeskLib:KernelSWIs.h"
  19. #include "DeskLib:SWI.h"
  20.  
  21.  
  22. extern BOOL OS_ReadVarVal(char *varname, char *buf, int bufsize)
  23. {
  24.   int result;
  25.   
  26.   /* Check for existence of this system variable */
  27.   SWI(3, 3, SWI_OS_ReadVarVal, varname, buf, -1, NULL, NULL, &result);
  28.   if (result < 0)
  29.   {
  30.     /* Variable exists - read it and use text for file description */
  31.     SWI(5, 3, SWI_OS_ReadVarVal,
  32.         varname, buf, bufsize, 0, 0,
  33.         NULL, NULL, &result);
  34.    
  35.     /* Ensure correct termination */
  36.     buf[result] = 0;
  37.  
  38.     return TRUE;
  39.   }
  40.   
  41.   /* Could not find it */
  42.   return FALSE;
  43. }      
  44.  
  45.